import request from '@/utils/request'
// id: 分类id，page: 页码，limit: 每次获取数据个数
// 获取图库分类列表
export function getImageCategoryList(data) {
  return request({
    url: `/image_class/${data.page}?limit=${data.limit}`,
    method: 'get'
  })
}

// 获取图库分类下图片列表
export function getImageList(data) {
  return request({
    url: `/image_class/${data.id}/image/${data.page}?limit=${data.limit}`,
    method: 'get'
  })
}

// 添加图库分类
export function addCategory(name, order) {
  return request({
    url: '/image_class',
    method: 'post',
    data: {
      name,
      order
    }
  })
}

// 上传图片
export function uploadImage(image_class_id, img) {
  return request({
    url: '/image/upload',
    method: 'post',
    data: {
      image_class_id,
      img
    }
  })
}

// 删除图片
export function deleteImage(ids) {
  return request({
    url: '/image/delete_all',
    method: 'post',
    data: {
      ids
    }
  })
}

// 修改图片名
export function updateImgName(id, name) {
  return request({
    url: `/image/${id}`,
    method: 'post',
    data: {
      name
    }
  })
}

// 修改分类
export function editCategory(id, name, order) {
  return request({
    url: `/image_class/${id}`,
    method: 'post',
    data: {
      name,
      order
    }
  })
}

// 删除分类
export function deleteCategory(id) {
  return request({
    url: `/image_class/${id}/delete`,
    method: 'post'
  })
}
